home *** CD-ROM | disk | FTP | other *** search
- /* strtol.c, from p.183 of Turbo C Bible */
- /* Converts a string to a long integer. */
- #include <stdio.h>
- #include <stdlib.h>
- main(int argc, char **argv)
- {
- char *stop_at; /* Marks where strtol stopped */
- int radix;
- long value;
- if(argc < 3)
- {
- printf("Usage: %s <value> <radix>\n", argv[0]);
- }
- else
- {
- radix = atoi(argv[2]);
- value = strtol(argv[1], &stop_at, radix);
- printf("Value read in radix %d = %ld\n"
- "Stopped at: %s\n", radix, value, stop_at);
- }
- }